<template>
    <div>
        
        <div class='father'>
            <index-left></index-left>
            <keep-alive exclude="ProductAdd,Editor,CMSAdd,CMSChange">
            <router-view v-if="isRouterAlive"></router-view>
            </keep-alive>
        </div>    
    </div>
</template>

<script>
import IndexLeft from './components/Left'
import IndexHeader from './components/Header'
 export default {
      name:'Index',
        components:{
            IndexLeft,
            IndexHeader
        },
        provide (){
            return {
                reload:this.reload
            }
        },
        data (){
            return {
                isRouterAlive:true
            
            }
        },
        mounted() {
            this.install()
        },
        methods: {
           reload (){
               this.isRouterAlive = false
               this.$nextTick(function(){
                   this.isRouterAlive = true
               })
           }, 
           install (){
               console.log(localStorage)
            //    console.log(localStorage.token)
                this.getLocalStorage('token')
               if(!localStorage.token){
                    this.$router.push('/')
                }
           },
           getLocalStorage(key){
                var info= localStorage.getItem(key);
                if(info) {
                    info = JSON.parse(info);
                    if (info.exp > new Date().getTime()) {
                        return info.val;
                    }
                    else{
                        this.deleteLocalStorage('token');
                    }
                }
            return '';
            },
            deleteLocalStorage:function(key){
                return localStorage.removeItem(key);
            },
        }
 }   
</script>

<style lang="stylus" scoped>
.father
    overflow hidden
</style>
